import com.pojo.Customer;
import com.pojo.Student;
import com.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class StudentTest {
    @Test
    public void findStudentByNameOrMajorTest() {
        SqlSession session = MyBatisUtils.getSession();
        Student student = new Student();
        student.setSname("张三");
        student.setMajor("《计算机应用技术》专家");
        List<Student> students = session.
                selectList("com.mapper.StudentMapper.findStudentByNameOrMajor",student);
        for (Student s : students) {
            System.out.println(s);
        }
        session.close();
    }
    @Test
    public void findByArrayTest(){
        SqlSession session = MyBatisUtils.getSession();
        Integer[] roleIds = {1,2,3,4};
        List<Student> students = session.selectList("com.mapper.StudentMapper.findStudentByIds",roleIds);
        for (Student student : students) {
            System.out.println(students);
        }
        session.commit();//查询可以不提交事务
        session.close();
    }
}